import service from "@/utils/request"
import LoginWork from "@/utils/LoginWork" 

// 入库明细查询
export interface QueryTheStorageDetailsInterface{
    vendors: vendors[],
    depts: depts[],
    slipReason:string[]
}

export interface vendors{
    vendorNo: string,
    vendorName: string
}

export interface depts{
   deptName: string,
   deptNo: string
}

export const QueryTheStorageDetails = () => {
    return service.get<any,QueryTheStorageDetailsInterface>('/pcFactorStockQuery/otherMtlInBack')
}

// 指令资料
export interface InstructionDataInterface{
    typeNo: string,
    typeName: string
}
export const InstructionData = (parms:string) => {
    return service.get<any,InstructionDataInterface[]>('/pcFactorStockQuery/otherComMtlBack',{
        params:{mtlType:parms}
    })
}

// 待入库明细
export interface WaitingForStorageDetailsInterface{
    lotNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: string,
    mtlUnit: string,
    qty: null | string,
    price: null | string,
    amt: null | string,
    remark: null,
    mtlNo: string
}

export const WaitingForStorageDetails = () => {
    return service.get<any,WaitingForStorageDetailsInterface[]>('/pcFactorStockQuery/getOtherMtlWaitQuery')
}

// 其他材料入库查询
export interface QueryOtherMaterialsInTheWarehouseParms{
    lotNo:string,
    mtlName:string,
    pageNum:number,
    pageSize:number,
    slipDateEnd:string,
    slipDateStart:string,
    slipNo:string,
    slipReason:string
}

export interface QueryOtherMaterialsInTheWarehouseInterface{
    total?: number,
    dtos: dtos[]
}

export interface dtos{
    slipNo: string,
    slipDate: string,
    slipReason: string,
    lotNo: null,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    qty: number,
    remark: null,
    mtlNo: string,
    deptName: string,
    amt: null,
    sysUser: string
}

export const QueryOtherMaterialsInTheWarehouse = (parms:QueryOtherMaterialsInTheWarehouseParms) => {
    return service.put<any,QueryOtherMaterialsInTheWarehouseInterface>('/pcFactorStockQuery/getOtherMtlInQuery',parms)
}


// 通用材料
export interface MaterialDetailParms{
    mtlColor:string,
    mtlName_1:string,
    mtlName_2:string,
    mtlName_3:string,
    mtlSpec:string,
    mtlTypeL:string,
    mtlTypeM:string,
    mtlTypeS:string,
    mtlUnit:string,
    pageNum:number,
    pageSize:number
}

export interface MaterialDetailInterface{
    total?: number,
    dtos: dtosMaterialDetail[]
}

export interface dtosMaterialDetail{
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null | string,
    mtlUnit: string
}

export const MaterialDetail = (parms:MaterialDetailParms) => {
    return service.put<any,MaterialDetailInterface>('/pcFactorStockQuery/getComMtlQuery',parms)
}

// 指令材料
export interface CommandMaterialParms{
    carNo:string,
    lotNo:string,
    mtlName:string,
    pageNum:number,
    pageSize:number,
    typeNo:string
}

export interface CommandMaterialInterface{
    total?: number,
    dtos: CommandMaterialDtos[]
}

export interface CommandMaterialDtos{
    lotNo: string,
    seqNo: number,
    partName: string,
    segment: number,
    mtlTypeNo: string,
    mtlType: string,
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    ttlUsage: number
}

export const CommandMaterial = (parms:CommandMaterialParms) => {
    return service.put<any,CommandMaterialInterface>('/pcFactorStockQuery/getLotMtlQuery',parms)
}


// 指令材料回显
export const CommandMaterialEcho = () => {
    return service.get<any,InstructionDataInterface[]>('/pcFactorStockQuery/otherLotMtlBack')
}

// 通用材料回显
export const GeneralMaterialEcho = (parms:string) => {
    return service.get<any,InstructionDataInterface[]>('/pcFactorStockQuery/otherLotComMtlBack',{
        params:{mtlType:parms}
    })
}

// 通用材料表格数据
export interface GeneralMaterialsFormDataParms{
    mtlName:string,
    mtlTypeL:string,
    mtlTypeS:string,
    pageNum:number,
    pageSize:number
}

export interface GeneralMaterialsFormDataInterface{
    total?: number,
    dtos: GeneralMaterialsFormDataDtos[]
}

export interface GeneralMaterialsFormDataDtos{
    mtlNo: string,
    mtlTypeNo: null,
    mtlTypeName: string,
    mtlName: string,
    mtlSpec: string,
    mtlColor: null,
    mtlUnit: string
}

export const GeneralMaterialsFormData = (parms:GeneralMaterialsFormDataParms) => {
    return service.put<any,GeneralMaterialsFormDataInterface>('/pcFactorStockQuery/getLotComMtlQuery',parms)
}

// 指令子材料
export interface InstructionSubmaterialParms{
    lotNo:string,
    mtlNo:string,
    seqNo:string
}

export const InstructionSubmaterial = (parms:InstructionSubmaterialParms) => {
    return service.put<any,any>('/pcFactorStockQuery/otherLotSubMtlQuery',parms)
}
 
// 入库批处理
export interface StorageBatchProcessingParms{
    slipReason:string,
    deptNo:string,
    deptName:string,
    mtlNo:string,

}
export const StorageBatchProcessing = (parms:any) => {
    return LoginWork.put<any,any>('/pcFactorStockQuery/otherMtlInStockAdd',parms)
}

// 新增
export interface newDateParms{
    lotNo:string,
    mtlNo:string,
    seqNo:string
}

export const newDate = (parms:newDateParms,type:number) => {
    return LoginWork.put<any,any>('/pcFactorStockQuery/otherMtlWaitStockAdd',parms,{
        params:{type:type}
    })
}

interface date{
    code:number,
    data:string,
    message:string
}

// 整单删除
export const CompleteOrder = (slipNo:string) => {
    return LoginWork.post<any,date>(`/pcFactorStockQuery/otherMtlStockDelete?slipNo=${slipNo}`,)
}





